#
# Unit Tests for JSON Arrays
#  Copyright (C) 2002 Rafael R. Sevilla <dido@imperium.ph>
#  This file is part of JSON for Ruby
#
#  JSON for Ruby is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public License
#  as published by the Free Software Foundation; either version 2.1 of
#  the License, or (at your option) any later version.
#
#  JSON for Ruby is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details. 
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with JSON for Ruby; if not, write to the Free
#  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
#  02111-1307 USA.
#
# Author:: Rafael R. Sevilla (mailto:dido@imperium.ph)
# Copyright:: Copyright (c) 2003 Rafael R. Sevilla
# License:: GNU Lesser General Public License
# $Id: arraytest.rb,v 1.2 2005/01/28 02:59:02 didosevilla Exp $
#

require 'test/unit'
require 'json/lexer'
require 'json/objects'

class ArrayTest < Test::Unit::TestCase
  def test_array_to_json
    array = Array.new
    array[0] = 'bar'
    array[1] = 1
    array[2] = 2.7182818

    str = array.to_json
    sarray = JSON::Lexer.new(str).nextvalue
    assert(sarray.class == Array, "array was not generated by deserialization")
    assert(sarray[0] == 'bar', "error in serialization of a string to JSON")
    assert(sarray[1] == 1, "error in serialization of a FixNum to JSON")
    assert(sarray[2] == 2.7182818, "error in serialization of a float to JSON")
  end
end
